package com.xiaoxintong.activity.base

import android.app.Activity
import android.app.AlertDialog
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.support.v4.content.LocalBroadcastManager
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView

/**
 * Created by zhangzhi on 16/7/18.
 */
abstract class BaseActivityK : AppCompatActivity() {
    var mContext: Activity? = null
    var toolbar: Toolbar? = null
    var rightButton: TextView? = null
    var root: LinearLayout? = null
    var textView: TextView? = null
    var dialog: AlertDialog? = null
    var dialogAction: String? = null
    val TAG = this.javaClass.simpleName

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (initView(savedInstanceState)) return
        requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        val contentView = View.inflate(this, layoutId, null)
        setContentView(contentView)
        mContext = this
        initView()
        initData()
    }

    protected fun initView(savedInstanceState: Bundle?): Boolean {
        return false
    }

    override fun setTitle(title: CharSequence) {
        super.setTitle(title)
        if (textView != null) {
            textView!!.text = title
        }
    }

    protected open fun initView() {}

    protected open fun initData() {}


    protected abstract val layoutId: Int


}
